package com.hmy.finance.service.receipt.dto.offset;

import com.hmy.finance.dal.po.DeviceDailyBillPo;
import com.hmy.finance.dal.po.json.ProfitLossInfoJson;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * Offset Device Daily Bill Data Transfer Object
 *
 * @author songkf
 */
@Data
public class OffsetDeviceDailyBillDto implements java.io.Serializable {

    private static final long serialVersionUID = -4478540390731594032L;

    /**
     * Device Daily Bill ID
     */
    private Long deviceDailyBillId;
    /**
     * Rental Amount
     */
    private BigDecimal rentalAmount;
    /**
     * ProfitLoss Amount
     */
    private BigDecimal profitLossAmount;
    /**
     * ProfitLoss Info List
     */
    private List<ProfitLossInfoJson> profitLossInfo;
    /**
     * Unpaid Amount
     */
    private BigDecimal unpaidAmount;
    /**
     * Fee Incurred Time
     */
    private LocalDateTime feeIncurredTime;
    /**
     * Is Termination
     */
    private Boolean isTermination;

    /**
     * Build Offset Device Daily Bill Data Transfer Object from Device Daily Bill
     *
     * @param deviceDailyBill the Device Daily Bill
     * @return the Offset Device Daily Bill Data Transfer Object
     */

    public static OffsetDeviceDailyBillDto buildFromDeviceDailyBill(DeviceDailyBillPo deviceDailyBill) {
        OffsetDeviceDailyBillDto offsetDeviceDailyBillDto = new OffsetDeviceDailyBillDto();
        offsetDeviceDailyBillDto.setDeviceDailyBillId(deviceDailyBill.getId());
        offsetDeviceDailyBillDto.setRentalAmount(deviceDailyBill.getFee());
        offsetDeviceDailyBillDto.setProfitLossAmount(deviceDailyBill.getTotalProfitLossAmount());
        offsetDeviceDailyBillDto.setProfitLossInfo(deviceDailyBill.getProfitLossInfo());
        offsetDeviceDailyBillDto.setUnpaidAmount(deviceDailyBill.getUnpaidAmount());
        offsetDeviceDailyBillDto.setFeeIncurredTime(deviceDailyBill.getFeeIncurredTime());
        return offsetDeviceDailyBillDto;
    }
}
